class Solution {
    public List<List<Integer>> threeSum(int[] nums) {
        List<List<Integer>> ret=new ArrayList<>();
        Arrays.sort(nums);
        int n=nums.length;
        for(int i=0;i<n;i++){
            int left=i+1;int right=n-1;int target=-nums[i];
            while(left<right){
                int sum=nums[left]+nums[right];
                if(sum<target){
…                }
                while(i<n-1&&nums[i]==nums[i+1])
                    i++;
            }
        }
        return ret;
    }
}